<template>
    <div id="forget" style="background-size: 100% 800px" :style="{ backgroundImage: 'url(' + Img + ')' }">
            <div class="department">
            <img :src='require("@/assets/images/Logo2.png")' alt="" class="lg_logo" />
            <div class="title">
                <a href="#" class="find_s">找回密码</a>
            </div>

            <form id="form">
                <!-- 手机号 -->
                <div class="input tel_d">
                    <span></span>
                    <div class="fl tel_div">
                        <input type="text" placeholder="请输入手机号" class="t_input" @blur="checkPhone" v-model="phone" autocomplete="off"/>
                    </div>
                </div>
                <!-- 手机号提示框 -->
                <div class="tel" v-show="show_tel">
                    <div class="tra"></div>
                    <a-icon type="warning" theme="twoTone" two-tone-color="red"/>&nbsp;&nbsp;手机号格式不对,请重新输入！
                </div>
                <!-- 密码 -->
                <div class="input pw_d">
                    <span></span>
                    <div class="fl npw">
                        <input type="password" placeholder="输入新密码" class="t_input" v-model="pw" autocomplete="off"/>
                    </div>
                </div>
                <!-- 请再输入密码 -->
                <div class="input input_rpw">
                    <span></span>
                    <div class="fl rpw">
                        <input type="password" placeholder="再输入新密码" class="t_input" v-model="rpw" @blur="isShow" autocomplete="off"/>
                    </div>
                </div>
                <div class="order" v-show="show_pw">
                    <div class="tra"></div>
                    <a-icon type="warning" theme="twoTone" two-tone-color="red"/>&nbsp;&nbsp;两次密码不同，<br />请重新输入！
                </div>
                <div class="input tacket_d">
                    <span></span>
                    <div class="fl ticket_div">
                        <input type="text" placeholder="请输入验证码" class="ticket" v-model="ticket"/>
                        <input type="button" value="验证码" class="code" @click="send" :disabled="Dodisabled" :style="style_un" autocomplete="off"/>
                    </div>
                </div>
                <input type="button" value="找回密码" class="btn" @click="submit" />
            </form>
        </div>
        <PageFooter></PageFooter>
    </div>
</template>
<script>
    import PageFooter from '../components/PageFooter.vue'
    export default{
        name: "Forget",
        data() {
            return {
                pw: "",
                rpw: "",
                phone: "",
                ticket:"",
                Img: require('@/assets/images/login.jpg'),
                show_pw: false,
                show_tel: false,
                Dodisabled:true,
                style_un:{
                    background:'#ccc',
                    cursor:'not-allowed'
                }
            };
        },
        created() {
            //在实例创建完成后被立即调用
        },
        components: {
            PageFooter
        },
        methods: {
            isShow() {
            if (this.pw != this.rpw) {
                this.show_pw = true;
            } else {
                this.show_pw = false;
            }
            },
            checkPhone() {
            const regMobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
            if (regMobile.test(this.phone)) {
                this.show_tel = false;
                this.Dodisabled=false;
                this.style_un={};
            } else {
                this.show_tel = true;
            }
            },
            send() {
                if(!this.show_tel){
                    this.$axios.get("http://192.168.43.99:8080/sms/send?phone=" + this.phone).then(
                        function (response) {
                            console.log(response);
                        },
                        function (error) {
                            console.log(error);
                        }
                    )
                }
                else{
                    alert("请重新输入！");
                }
            },
            submit(){
                if(this.pw!=""&&this.rpw!=""&&this.ticket!=""&&this.phone!=""&&!this.show_pw&&!this.show_tel){
                this.$axios.post("https://pms.xybh.online/register/user",
                {"password":this.pw,"phone":this.phone,"ticket":this.ticket})
                .then(
                function (response) {
                    console.log(response);
                },
                function (error) {
                    console.log(error);
                })
            }
            else{
                alert("请重新输入！");
            }
            }
        },
    }
</script>
<style scoped>
    .ticket{
        width: 118px;
    }
    .ticket_div {
        border-bottom: 2px solid #666;
    }
    .ticket_d {
        margin-top: 15px;
    }
    .pw_d {
        margin-top: 15px;
    }
    .tel_d {
        margin-top: 15px;
    }
    .tel_div {
        border-bottom: 2px solid #666;
    }
    .lg_logo {
        width: 100px;
        height: 100px;
        margin-top: 105px;
    }
    .find_s {
        margin-right: 10px;
        color: #00a1ff;
    }
    .input_rpw {
        margin-top: 15px;
    }
    .username {
        border-bottom: 2px solid #666;
    }
    .npw {
        border-bottom: 2px solid #666;
    }
    .btn {
        width: 175px;
        height: 32px;
        margin-top: 30px;
        background-color: #0e60ff;
        color: white;
    }
    #form {
        position: relative;
    }
    .rpw {
        border-bottom: 2px solid #666;
    }
    .code {
        width: 80px;
        height: 29px;
        background: #00a1ff;
        color: white;
        cursor: pointer;
    }
    .tra {
        position: absolute;
        top: 13px;
        left: -20px;
        width: 0;
        height: 0;
        line-height: 0;
        font-size: 0;
        border: 10px solid transparent;
        border-right-color: #fff;
    }
    .order {
        position: absolute;
        left: 230px;
        top: 80px;
        width: 150px;
        height: 60px;
        padding: 5px;
        border-radius:10px;
        box-shadow: #efefef 5px 5px 5px 5px;
        border: 2px solid transparent;
        color: black;
        background-color: #fff;
    }
    .tacket {
        width: 118px;
    }
    .tel {
        position: absolute;
        left: 218px;
        top: -10px;
        width: 150px;
        height: 60px;
        padding: 5px;
        border-radius:10px;
        box-shadow: #efefef 5px 5px 5px 5px;
        color: black;
        background-color: #fff;
    }
    @font-face {
        font-family: "icomoon";
        src: url("../assets/fonts/icomoon.eot?we8owe");
        src: url("../assets/fonts/icomoon.eot?we8owe#iefix")
            format("embedded-opentype"),
            url("../assets/fonts/icomoon.ttf?we8owe") format("truetype"),
            url("../assets/fonts/icomoon.woff?we8owe") format("woff"),
            url("../assets/fonts/icomoon.svg?we8owe#icomoon") format("svg");
        font-weight: normal;
        font-style: normal;
        font-display: block;
    }
    html, body {
        height: 100%;
        margin: 0;
        padding: 0;
    }
    a {
        text-decoration: none;
        color: black;
    }
    .fl {
        float: left;
    }
    .fr {
        float: right;
    }
    form {
        width: 225px;
        margin: auto auto;
    }
    input {
        outline-style: none;
        border: none;
        background-color:rgba(235,235, 235, .6);
        font-size: 16px;
        color: black;
    }
    #foeget{
        height: 100%;
        width: 100%;
    }
    .department {
        width: 350px;
        height: 800px;
        background-color:rgba(235,235, 235, .5);
        text-align: center;
    }
    .lg_logo {
        width: 100px;
        height: 100px;
        margin-top: 105px;
    }

    .blue {
        width: 56px;
        height: 36px;
        color: #15a7fd;
    }
    .gray {
        width: 56px;
        height: 36px;
        color: #9c9c9c;
    }
    .title {
        font-size: 28px;
        font-family: Segoe UI, Segoe UI-Regular;
        margin: 35px auto;
    }
    .input {
        width: 250px;
        height: 30px;
    }

    .input span {
        float: left;
        width: 27px;
        height: 27px;
        font-family: "icomoon";
        font-size: 27px;
    }
    .t_input {
        width: 180px;
        height: 24px;
        padding-left: 7px;
    }
    .add {
        height: 19px;
        text-align: center;
    }
    .rem {
        width: 84px;
    }
    .btn {
        width: 175px;
        height: 30px;
        margin-top: 30px;
        background-color: #0e60ff;
        color: white;
    }
    .sport_qq {
        width: "48px";
        height: "48px";
        float: left;
        margin-left: 10px;
        font-family: "icomoon";
        font-size: 36px;
    }
    .sport {
        width: "48px";
        height: "48px";
        float: left;
        margin-left: 58px;
        font-family: "icomoon";
        font-size: 36px;
    }
</style>
